package ch.nostromo.tiffanys.game.move;


public class Move implements Cloneable {

  /** From (cloned) */
  private String from = "";

  /** To (cloned) */
  private String to = "";

  /** Promotion piece (cloned) */
  private int promotion = 0;

  /** Starting piece (cloned) */
  private int startingPiece;

  /** Is move scored (cloned) */
  private boolean isScored = false;

  /** Score (cloned) */
  private int score = -1;

  /** Score depth (cloned) */
  private int scoreDepth = -1;
  
  /** Score tree (cloned) */
  private Move[] scoreTree = null;

  /** Is short castlig (cloned) */
  private boolean isCastlingShort;
  
  /** Is long castling (cloned) */
  private boolean isCastlingLong;

  /** Is strike move (cloned) */
  private boolean isStrikeMove;

  /** Is check move (cloned) */
  private boolean checks;

  /** Is mate move (cloned) */
  private boolean mates;

  /** San description (cloned) */
  private String sanDescription;

  @Override
  public Move clone() throws CloneNotSupportedException {
    Move result = (Move) super.clone();
    
    if (scoreTree != null) {
      result.scoreTree = new Move[scoreTree.length];
      for (int i = 0; i < scoreTree.length; i ++) {
        result.scoreTree[i] = scoreTree[i];
      }
    }
    
    return result;
  }
  
  public Move(String from, String to, int startingPiece, int promotion, boolean isScored, int score, int scoreDepth, Move[] scoreTree, boolean isCastlingShort, boolean isCastlingLong, boolean isStrikeMove, boolean checks, boolean mates) {
    this.from = from;
    this.to = to;
    this.startingPiece = startingPiece;
    this.promotion = promotion;

    this.isScored = isScored;

    this.score = score;
    this.scoreDepth = scoreDepth;

    this.scoreTree = scoreTree;
    this.isCastlingShort = isCastlingShort;
    this.isCastlingLong = isCastlingLong;
    this.isStrikeMove = isStrikeMove;

    this.mates = mates;
    this.checks = checks;
  
  }

  public boolean isPromotion() {
    return promotion != 0;
  }

  public int getPromotion() {
    return promotion;
  }

  public String getFrom() {
    return from;
  }

  public String getTo() {
    return to;
  }

  public boolean isScored() {
    return isScored;
  }

  public int getScore() {
    return score;
  }

  public Move[] getScoreTree() {
    return scoreTree;
  }

  public boolean isCastlingLong() {
    return isCastlingLong;
  }

  public boolean isCastlingShort() {
    return isCastlingShort;
  }

  public boolean isStrikeMove() {
    return isStrikeMove;
  }

  public int getStartingPiece() {
    return startingPiece;
  }

  public boolean checks() {
    return checks;
  }

  public void setChecks(boolean checks) {
    this.checks = checks;
  }

  public boolean mates() {
    return mates;
  }

  public void setMates(boolean mates) {
    this.mates = mates;
  }

  public String getSanDescription() {
    return sanDescription;
  }

  public void setSanDescription(String sanDescription) {
    this.sanDescription = sanDescription;
  }

  public int getScoreDepth() {
    return scoreDepth;
  }

  public void setScoreDepth(int scoreDepth) {
    this.scoreDepth = scoreDepth;
  }

}
